package com.design.prototype;

import java.util.ArrayList;
import java.util.List;

public class PrototypePattern {

    public static void main(String[] args) throws CloneNotSupportedException {
        BeanA beanA = new BeanA();
        BeanA beanA1 = beanA.cloneBean();
        System.out.println(beanA);
        System.out.println(beanA1);
        System.out.println(beanA.f3 == beanA1.f3);

    }

   public static class BeanA implements Cloneable{
        private String f0;
        private String f1;
        private String f2;
        private List<String> f3 = new ArrayList<>();

        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }

        public BeanA cloneBean() throws CloneNotSupportedException {
            return (BeanA) clone();
        }

    }

    static class BeanB implements Cloneable{
        private String f0;
        private String f1;
        private String f2;
        private List<String> f3;
        @Override
        protected Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }
}


